﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;

namespace OracleDAL.SystemManager
{
   public class SystemManager
   {
       /// <summary>
       /// 获取备份的数据集
       /// </summary>
       /// <returns></returns>
       public DataSet getDs(string whereStr)
       {
           string sqlStr = "select SCHEMEID,SCHEMENAME,SCHEMETYPE,EXCUTTIME,SPLTTYPE,EFFECTVALUE,BACKTIME,ISUSED,to_char(segmentpoint,'hh:mi:ss') as segmentpoint,daytime from systemmanagescheme where " + whereStr;
           return DBUtility.OracleHelper.Query(sqlStr);
       }
       /// <summary>
       /// 
       /// </summary>
       /// <param name="id"></param>
       /// <returns></returns>
       public int deleteManager(string id)
       {
           string sqlStr = "delete from  systemmanagescheme where SCHEMEID='"+id+"'";
           return DBUtility.OracleHelper.ExecuteSql(sqlStr);
       }
       public int addAndUpdate(string SCHEMEID, string SCHEMENAME, string SCHEMETYPE, string EXCUTTIME, string SPLTTYPE, string EFFECTVALUE, string BACKTIME, string type, string segmentTime, string dayTime)
       {
           int result = 0;
           string strSql = "";
           try
           {
               if (type == "1")
               {
                   strSql = "insert  into systemmanagescheme (SCHEMEID,SCHEMENAME,SCHEMETYPE,EXCUTTIME,SPLTTYPE,EFFECTVALUE ,BACKTIME,ISUSED,segmentpoint,daytime) values('" + SCHEMEID + "','" + SCHEMENAME + "','" + SCHEMETYPE + "'," + EXCUTTIME + ",'" + SPLTTYPE + "','" + EFFECTVALUE + "'," + BACKTIME + ",'0'," + segmentTime + ",'" + dayTime + "')";
                   result = DBUtility.OracleHelper.ExecuteSql(strSql);

               }
               else if (type == "2")
               {
                   strSql = "update systemmanagescheme set SCHEMENAME='" + SCHEMENAME + "',SCHEMETYPE='" + SCHEMETYPE + "',EXCUTTIME=" + EXCUTTIME + ",SPLTTYPE='" + SPLTTYPE + "',EFFECTVALUE='" + EFFECTVALUE + "',BACKTIME=" + BACKTIME + ",segmentpoint=" + segmentTime + ",daytime='" + dayTime + "' where SCHEMEID='" + SCHEMEID + "'";
                   result = DBUtility.OracleHelper.ExecuteSql(strSql);

               }
           }
           catch (Exception e)
           {

           }
           return result;
       }
       /// <summary>
       /// 设置是否生效
       /// </summary>
       /// <param name="id">方案id</param>
       /// <param name="type">类型（0 无效，1有效 ）</param>
       /// <returns></returns>
       public int setUsed(string id, string type)
       {
           int result = 0;
           string strSql = "update systemmanagescheme set isused='" + type + "' where SCHEMEID='"+id+"' ";
           result =DBUtility.OracleHelper.ExecuteSql(strSql);
           return result;
       }
    }
}
